//上海  31.2037720195,121.4718818665

//22.852828925,113.4640653811  loc=116.3187789917,39.9715950147

//新用户邀请领券-15
function share_refer(user_id, phone) {
    let url = "https://h5.ele.me/restapi/marketing/promotion/refer/" + user_id;
    r = http.postJson(url, {
        refer_code: "1a80bcc38970a5d68e3f721fc0827a75",
        refer_user_id: "928585962",
        phone: phone,
        platform: "3",
        latitude: "31.2037720195",
        longitude: "121.4718818665",
        refer_channel_code: "1",
        refer_channel_type: "3",
    }, share_refer_Headers());
    let a = r.body.json()['promotion_items'][0]['amount'];
    if (a == 15) {
        return "新用户首单-" + a;
    } else {
        return 0;
    }
}

function share_refer_Headers(cookie) {
    return {
        headers: {
            'Host': 'h5.ele.me',
            'Connection': 'keep-alive',
            'Content-Length': '220',
            'Origin': 'https://h5.ele.me',
            'User-Agent': 'NOKIA5700/ UCWEB7.0.2.37/28/999',
            'DNT': '1',
            'content-type': 'application/json; charset=utf-8',
            'Accept': '*/*',
            'Referer': 'https://h5.ele.me/fire/water/?refer_id=928585962&refer_code=1a80bcc38970a5d68e3f721fc0827a75&refer_channel_code=1&refer_channel_type=3',
            'Accept-Encoding': 'gzip, deflate, br',
            'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'Cookie': cookie,
        }
    }
}

//新用户50礼包(11.14)
function wushilb(user_id) {
    let url = "https://h5.ele.me/restapi/marketing/v3/users/" + user_id + "/new_user_gifts?geohash=wtw3s0mphh8n2nbj3&physical_geohash=wtw3s0mphh8n2nbj3&logical_geohash=wtw3s0mphh8n2nbj3&device_id=";
    var r = http.get(url, wushilb_headers());
    return r.body.json()['hongbaos'][0];
}

function wushilb_headers() {
    return {
        headers: {
            'Host': 'h5.ele.me',
            'Connection': 'keep-alive',
            'Origin': 'https://h5.ele.me',
            'X-Shard': 'loc=121.4418213441968,31.2085853330791',
            'User-Agent': 'Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; MI 5s Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 Quark/2.4.6.935 Mobile Safari/537.36',
            'DNT': '1',
            'Accept': '*/*',
            'Referer': 'https://h5.ele.me/newuser/?activity_ids=%5B10142481%5D',
            'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'Cookie': cookie,
        }
    }
}

//新用户80礼包果蔬-13(11.14)
function bashilb(user_id) {
    let url = "https://h5.ele.me/restapi/marketing/v1/users/" + user_id + "/new_user_mission/rewards?user_id=" + user_id + "&device_id=&latitude=31.2037720195&longitude=121.4718818665";
    var r = http.get(url, bashilb_headers());
    return r.body.json();
}

function bashilb_headers() {
    return {
        headers: {
            'Host': 'h5.ele.me',
            'Connection': 'keep-alive',
            'X-Shard': 'loc=121.4418213441968,31.2085853330791',
            'User-Agent': 'Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; MI 5s Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 Quark/2.4.6.935 Mobile Safari/537.36',
            'DNT': '1',
            'Accept': '*/*',
            'Referer': 'https://h5.ele.me/newuser/newmission/',
            'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'Cookie': cookie,
        }
    }
}
